package com.espirit.builder.base;

import com.espirit.eap.manager.ModelBuilderSupport;
import com.espirit.eap.pagelayout.GridSection;
import com.espirit.eap.pagelayout.ModelField;

public abstract class PartyBuilderSupport extends ModelBuilderSupport {
	public static final String NAME="name";
	public static final String CODE="code";
	public static final String DESCRIPTION="description";
	public static final String FIELD_ID="id";
	
	
	protected ModelField mfName;
	protected ModelField mfDescription;
	@Override
	public boolean init() {
		return true;
	}
	
	@Override
	public void buildFields() {
		addModelFieldCode("Code", "代码");
		addModelFieldName("Name", "名称");
		addModelField(FIELD_ID, "Id", "Id");
		
		addModelField(DESCRIPTION, "Description", "描述");
	}
	
	protected ModelField addModelFieldCode(String enName,String cnName){
		ModelField mf = addModelField(CODE, enName, cnName);
		return mf;
		
	}
	protected void addModelFieldName(String enName,String cnName){
		addModelField(NAME, enName, cnName);

	}
	
	@Override
	public void prepareLayoutElements() {
		mfName = getModelField(NAME);
		mfDescription = getModelField(DESCRIPTION);

		addListField(mfName,mfDescription);
		addDetailField(mfName,mfDescription);
		
		setRequired(NAME);
		super.prepareLayoutElements();
	}
	
	protected void setListElementLength(GridSection gridSection ,String fieldName , int length ){
		if (gridSection == null) return ;
		setSearchResultElementWidth(gridSection,fieldName, length);
	}
	

}
